package com.shujia.spark.core

import org.apache.spark.{SparkConf, SparkContext}

object Demo6Sample {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("Demo4Filter")

    val sc = new SparkContext(conf)

    val studentRDD = sc.textFile("spark/data/students.txt")

    /**
      * sample  抽样
      * withReplacement  是否放回
      * fraction  抽样比例
      *
      */
    val sampleRDD = studentRDD.sample(true, 0.1)

    sampleRDD.foreach(println)
  }

}
